ConcurrentDictionary(TKey, TValue) Constructor (Int32, IEnumerable(KeyValuePair(TKey, TValue)), IEqualityComparer(TKey))

Task Parallel System.Threading

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
	concurrencyLevel As Integer, _
	collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), _
	comparer As IEqualityComparer(Of TKey) _
)
C#
public ConcurrentDictionary(
	int concurrencyLevel,
	IEnumerable<KeyValuePair<TKey, TValue>> collection,
	IEqualityComparer<TKey> comparer
)

Parameters

concurrencyLevel
Type: System..::.Int32
The estimated number of threads that will update the ConcurrentDictionary<(Of <(TKey, TValue>)>) concurrently.
collection
Type: System.Collections.Generic..::.IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)
The IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>) whose elements are copied to the new ConcurrentDictionary<(Of <(TKey, TValue>)>).
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
The IEqualityComparer<(Of <(TKey>)>) implementation to use when comparing keys.

Exceptions

ExceptionCondition
System..::.ArgumentNullException collection is a null reference (Nothing in Visual Basic). -or- comparer is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException concurrencyLevel is less than 1.
System..::.ArgumentExceptioncollection contains one or more duplicate keys.

See Also